import { createI18n } from "vue-i18n";

const saved = localStorage.getItem("lang");
const defaultLocale =
  saved ||
  (navigator.language?.toLowerCase().startsWith("en") ? "en-US" : "zh-CN");

const messages = {
  "zh-CN": {
    nav: {
      home: "首页",
      about: "关于我们",
      exhibitorCenter: "展商中心",
      visitorCenter: "观众中心",
      activityCenter: "同期活动",
      mediaCenter: "新闻媒体",
      downloads: "下载中心",
      contact: "联系我们",
      productMall: "展品商城",
    },
    about: {
      exhibitionIntro: "展会介绍",
      productScope: "展品范围",
      exhibitionHighlights: "展会集锦",
      venueIntro: "展馆介绍",
      organizerIntro: "主办方介绍",
      organizationStructure: "组织架构",
      pastExhibitions: "往届展会",
    },
    exhibitor: {
      whyExhibit: "为何参展",
      whoExhibits: "谁来观展",
      exhibitRegistration: "参展报名",
      exhibitorSystem: "展商系统",
      exhibitorServices: "展商服务",
      exhibitorReviews: "展商评价",
    },
    visitor: {
      visitorTSubtitle1: "观众登记",
      visitorTSubtitle2: "观众服务",
      groupVisit: "组团参观",
      prereg: "观众预登记",
      notice: "观众须知",
      visaSystem: "签证申请",
      visitorRoster: "展商名录",
      visitorReviews: "观众评语",
    },
    activity: {
      calendar: "活动日历",
      forum: "行业论坛",
      techExchange: "技术交流会",
      businessMatching: "商务对接",
      productRelease: "产品发布",
      overview: "其他活动",
    },
    media: {
      exhibitionNews: "展会资讯",
      mediaReports: "媒体报道",
      industryNews: "行业资讯",
      onSiteHighlights: "现场集锦",
      cooperativeMedia: "合作媒体",
      mediaRegistration: "媒体注册",
    },
    action: {
      login: "登录",
      registerNow: "立即报名",
    },
    lang: {
      zh: "中文",
      en: "English",
    },
  },
  "en-US": {
    nav: {
      home: "Home",
      about: "About",
      exhibitorCenter: "Exhibitors",
      visitorCenter: "Visitors",
      activityCenter: "Events",
      mediaCenter: "Media",
      downloads: "Downloads",
      contact: "Contact",
      productMall: "Product Mall",
    },
    about: {
      exhibitionIntro: "Exhibition Intro",
      productScope: "Product Scope",
      exhibitionHighlights: "Highlights",
      venueIntro: "Venue Intro",
      organizerIntro: "Organizer",
      organizationStructure: "Organization",
      pastExhibitions: "Past Exhibitions",
    },
    exhibitor: {
      whyExhibit: "Why Exhibit",
      whoExhibits: "Who Exhibits",
      exhibitRegistration: "Exhibit Registration",
      exhibitorSystem: "Exhibitor System",
      exhibitorServices: "Exhibitor Services",
      exhibitorReviews: "Exhibitor Reviews",
    },
    visitor: {
      visitorTSubtitle1: "Audience Registration",
      visitorTSubtitle2: "Audience Services",
      groupVisit: "Group Visit",
      prereg: "Pre-registration",
      notice: "Visitor Notice",
      visaSystem: "Visa",
      visitorRoster: "Exhibitors Directory",
      visitorReviews: "Visitor Reviews",
    },
    activity: {
      calendar: "Calendar",
      forum: "Forum",
      techExchange: "Tech Exchange",
      businessMatching: "Business Matching",
      productRelease: "Product Release",
      overview: "Other Activities",
    },
    media: {
      exhibitionNews: "Exhibition News",
      mediaReports: "Media Reports",
      industryNews: "Industry News",
      onSiteHighlights: "On-site Highlights",
      cooperativeMedia: "Cooperative Media",
      mediaRegistration: "Media Registration",
    },
    action: {
      login: "Login",
      registerNow: "Register",
    },
    lang: {
      zh: "中文",
      en: "English",
    },
  },
};

const i18n = createI18n({
  legacy: false,
  locale: defaultLocale,
  fallbackLocale: "zh-CN",
  messages,
  silentFallbackWarn: true,
  silentTranslationWarn: true,
  missingWarn: false,
  fallbackWarn: false,
});

export default i18n;
